import request from '@/utils/request'
/**
 * 获取用户信息
 * @param {Strnig} mobile
 * @param {String} code
 * @returns
 */
export function reqGetUserInfo(mobile, code) {
  return request.post('/v1_0/authorizations', {
    mobile, code
  })
}
/**
 * 发送验证码
 * @param {String} mobile 手机号
 * @returns
 */
export function reqSendCode(mobile) {
  return request.get('/v1_0/sms/codes/' + mobile)
}

/**
 * 刷新token
 * @param {*} refresh
 * @returns
 */
export const reqRefreshToken = (refresh) => {
  return request({
    method: 'put',
    url: '/v1_0/authorizations',
    headers: {
      Authorization: 'Bearer ' + refresh
    }
  })
}
/**
 * 获取个人资料
 * @returns
 */
export const reqPersonalInfo = () => {
  return request({
    method: 'get',
    url: '/v1_0/user'
  })
}
/**
 * 详细资料
 * @returns
 */
export const reqDetailInfo = () => request.get('/v1_0/user/profile')
export const reqUpdateUserInfo = (obj) => {
  return request({
    method: 'patch',
    url: '/v1_0/user/profile',
    data: obj
  })
}

export const reqUploadImg = formData => request.patch('/v1_0/user/photo', formData)
// export const reqUploadImg = formData => request.patch('/v1_0/user/photo'[,data[,formData]])

// export const reqUploadImg = (formData) => {
//   return request({
//     method: 'patch',
//     url: '/v1_0/user/photo',
//     data: formData
//   })
// }
